package zack.gateway.core.datasource.unpooled;

import zack.gateway.core.datasource.DataSource;
import zack.gateway.core.datasource.DataSourceFactory;
import zack.gateway.core.datasource.DataSourceType;
import zack.gateway.core.session.Configuration;

/**默认网关会话工厂，创建session
 * @author A1793
 */
public class UnpooledDataSourceFactory implements DataSourceFactory {

    protected UnpooledDataSource dataSource;

    public UnpooledDataSourceFactory() {
        dataSource = new UnpooledDataSource();
    }

    @Override
    public void setProperties(Configuration configuration, String uri) {
        dataSource.setHttpStatement(configuration.getHttpStatement(uri));
        dataSource.setConfiguration(configuration);
        dataSource.setType(DataSourceType.DUBBO);
    }

    @Override
    public DataSource getDataSource() {
        return this.dataSource;
    }
}
